<template>
	<view class="myBox">
		<view class="myTop">
			<view class="topLeft">
				<image :src="info.avatar" mode=""></image>
				<view class="lvs ft_12" >
					{{info.vip_name}}
				</view>
			</view>
			<view class="topRight">
				<view style="font-weight: bold;">{{info.nickname}}</view>
				<view class="topName">用户编号：{{info.user_sn}}</view>
			</view>
			<view class="topRights" @tap="goPersonal">个人资料 ></view>
		</view>
		<view class="myBuy">
			<view class="buyTop">
				<view>我的订单</view>
				<view class="allList" @tap="allOrder()">查看></view>
			</view>
			<view class="buList">
				<view class=""  v-for="(item,index) in buyList" :key="index" @tap="goShop(index)">
					<view class="">
						<image :src="item.icon" mode=""></image>
					</view>
					<view class="">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<view class="myMoney display">
			<view class="moneyList" @tap="goMingxi(1)">
				<view class="top">{{info.integral}}</view>
				<view class="topName">积分</view>
			</view>
			<view class="moneyList" @tap="go_jflog()"  >
				<view class="top">{{info.commission}}</view>
				<view class="topName">佣金</view>
			</view>
		<!-- 	<view class="moneyList" @tap="go_my_pai()"  >
				<view class="top">{{info.buy_num?info.buy_num:0}}条</view>
				<view class="topName">排返队列</view>
			</view> -->
			<!-- <view class="moneyList"  @tap="goMingxi(2)">
				<view class="top">{{info.red_money}}</view>
				<view class="topName">红包券</view>
			</view>
			<view class="moneyList" @tap= 'goJifen'>
				<view class="top">{{info.score}}</view>
				<view class="topName">我的积分</view>
			</view> -->
		</view>
		<view class="myBtm">
<!--      list-->
      <view  v-if="info.level == 0 ">
        <view
            class="myList"
            v-for="(item,index) of menuNocoList"
            :key="index"
            @click='obtain(item.url,item.name)'
        >
          <view class="img">
            <image :src="item.icon" mode=""></image>
          </view>
          <view class="listName">{{item.name}}</view>
          <view class="right">
            <u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
          </view>

        </view>
      </view>
      <view  v-else>
        <view
            class="myList"
            v-for="(item,index) of menuList"
            :key="index"
            @click='obtain(item.url,item.name)'
        >
          <view class="img">
            <image :src="item.icon" mode=""></image>
          </view>
          <view class="listName">{{item.name}}</view>
          <view class="right">
            <u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
          </view>

        </view>
      </view>

      </view>
			<button open-type="contact" class="myBtm">联系客服</button>
		
		
		
		
		<u-popup v-model="show" mode="center">
			<view class="showBox">
				<view class="showName">
					积分签到
				</view>
				<view class="showBoxs display just_space">
					<view class="showOne" :class="{ bg :singInfo[0].is_sign==1}">
						<view class="name">第一天</view>
						<view class="">+{{singInfo[0].jf}}</view>
					</view>
					<view class="showTwo" :class="{ bg : singInfo[1].is_sign==1 }">
						<view class="name">第二天</view>
						<view class="">+{{singInfo[1].jf}}</view>
					</view>
					<view class="showTwo" :class="{ bg : singInfo[2].is_sign==1 }">
						<view class="name">第三天</view>
						<view class="">+{{singInfo[2].jf}}</view>
					</view>
					<view class="showFour" :class="{ bg : singInfo[3].is_sign==1}">
						<view class="name">第四天</view>
						<view class="">+{{singInfo[3].jf}}</view>
					</view>
					<view class="showFive" :class="{ bg : singInfo[4].is_sign==1}">
						<view class="name">第五天</view>
						<view class="">+{{singInfo[4].jf}}</view>
					</view>
					<view class="showTwo" :class="{ bg : singInfo[5].is_sign==1 }">
						<view class="name">第六天</view>
						<view class="">+{{singInfo[5].jf}}</view>
					</view>
					<view class="showSeven" :class="{ bg : singInfo[6].is_sign==1 }">
						<view class="name">第七天</view>
						<view class="">+{{singInfo[6].jf}}</view>
					</view>
				</view>
				<view class="showBtn" @tap="goQian">点击签到</view>
				<view class="showText">您已连续签到<text>{{sing.days}}天</text>获得<text>{{sing.all_jf}}积分</text></view>
			</view>
		</u-popup>
		<tab-bar ref='tabbar'></tab-bar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				buyList:[{
					icon:'../../static/zhifu.png',
					name:'待支付'
				},{
					icon:'../../static/fahuo.png',
					name:'待发货'
				},{
					icon:'../../static/shouhuo.png',
					name:'待收货'
				},{
					icon:'../../static/wancheng.png',
					name:'已完成'
				}],
        menuList:[
				// {
				// 	icon:'../../static/fenxiao.png',
				// 	name:'分销中心',
				// 	url:'distCenter'
				// },
				// {
				// 	icon:'../../static/fenxiao.png',
				// 	name:'兑换大潜',
				// 	url:'buy_jf'
				// },
				
				// {
				// 	icon:'../../static/erCode.png',
				// 	name:'兑换代理',
				// 	url:'buyAgent'
				// },
				// {
				// 	icon:'../../static/erCode.png',
				// 	name:'申请联创',
				// 	url:'apply_lc'
				// },
				// {
				// 	icon:'../../static/fenxiao.png',
				// 	name:'商家入驻',
				// 	url:'store_apply'
				// },
				
				{
					icon:'../../static/shouhuos.png',
					name:'收货地址',
					url:'address/address'
				},{
					icon:'../../static/shoucang.png',
					name:'我的收藏',
					url:'merchant'
				},
       /*   {
					icon:'../../static/tongzhi.png',
					name:'消息通知',
					url:'message'
				},*/
             {
        icon:'../../static/fenxiao.png',
        name:'我的团队',
        url:'myTeam'
      },
				
				// {
				// 	icon:'../../static/jifen.png',
				// 	name:'积分签到',
				// 	url:'myIntegra'
				// },
				// {
				// 	icon:'../../static/youhui.png',
				// 	name:'优惠券',
				// 	url:'coupon'
				// }
				
				
				{
					icon:'../../static/erCode.png',
					name:'我的二维码',
					url:'erCode'
				},
				{
					icon:'../../static/money.jpg',
					name:'提现',
					url:'drawMoney'
				}],
        menuNocoList:[
          {
            icon:'../../static/shouhuos.png',
            name:'收货地址',
            url:'address/address'
          },{
            icon:'../../static/shoucang.png',
            name:'我的收藏',
            url:'merchant'
          },
          {
            icon:'../../static/fenxiao.png',
            name:'我的团队',
            url:'myTeam'
          },
          {
            icon:'../../static/money.jpg',
            name:'提现',
            url:'drawMoney'
          }],
				name:'',
				schoolid:'',
				avavtar:'../../static/myPhoto.png',
				info:{
					avatar:'../../static/myPhoto.png',
					username:'请登录'
				},
				singInfo:[],
				sing:{}
			}
		},
		onLoad() {
			// uni.setStorageSync('selectedIndex', 3);
		},
		onShow() {
      this.$refs.tabbar.getCount();
      uni.setStorageSync('selectedIndex', 3);
			this.getUser()
			this.getQian()
		},
		methods: {
			go_my_pai(){
				uni.navigateTo({
					url:'paidui'
				})
			},
			go_jflog(){
				uni.navigateTo({
					url:'jf_log'
				})
			},
			obtain(e,name){
				if(name=='积分签到'){
					this.show = true
				}else{
					uni.navigateTo({
						url:e
					})
				}
				
			},
			getQian(){
				this.$myRequest({
					url: 'api/user/sign_log',
					method:'POST',
				}).then(res => {
					console.log(res.data);
					if(res.data.code==1){
						let data=res.data.data
						this.singInfo = data.other
						this.sing = data
						// this.info = data.info
					}else if(res.data.code==401){
						uni.showToast({
							icon:'none',
							title:'请先去登录'
						})
						setTimeout(function() {
							uni.navigateTo({
								url:'../wxLogin'
							})
						}, 1000);
					}
				})
			},
			goPersonal(){
				uni.navigateTo({
					url:'myInfo'
				})
			},
			allOrder(){
				uni.navigateTo({
					url:'order/order'
				})
			},
			goMingxi(e){//明细
				uni.navigateTo({
					url:'mingxi?type='+e
				})
			},
			goJifen(){
				uni.navigateTo({
					url:'jifenDetail'
				})
			},
			goQian(){
				
				this.$myRequest({
					url: 'api/user/user_sign ',
					method:'POST',
				}).then(res => {
					console.log(res.data);
					if(res.data.code==1){
						let data=res.data.data
						this.show = false
						 uni.showToast({
						 	icon:'none',
							title:res.data.msg
						 })
						this.getUser()
						this.getQian()
					}else if(res.data.code==401){
						uni.showToast({
							icon:'none',
							title:'请先去登录'
						})
						setTimeout(function() {
							uni.navigateTo({
								url:'../wxLogin'
							})
						}, 1000);
					}else{
						this.show = false
						 uni.showToast({
						 	icon:'none',
							title:res.data.msg
						 })
					}
				})
			},
			getUser(){
				this.$myRequest({
					url: 'api/user/index',
					method:'POST',
				}).then(res => {
					console.log(res.data);
					if(res.data.code==1){
						let data=res.data.data
						this.info = data.info
						console.log(this.info,'111111111111111111111111');
						uni.setStorageSync('uid',data.info.id)
					}else if(res.data.code==401){
						uni.showToast({
							icon:'none',
							title:'请先去登录'
						})
						setTimeout(function() {
							uni.navigateTo({
								url:'../wxLogin'
							})
						}, 1000);
					}
				})
			},
			goShop(num){
				uni.navigateTo({
					url:'order/order?type='+parseInt(num+1)
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #FAFAFA;
		overflow-y: auto;
		padding-bottom:50rpx;
	}
.myBox{
	width: 90%;
	margin: auto;
	.myTop{
		height: 200rpx;
		
		opacity: 1;
		display: flex;
		padding-left: 16px;
		color: #fff;
		.topLeft{
			line-height: 200rpx;
			position: relative;
			// color: #333333;
			image{
				width:120rpx;
				height: 120rpx;
				border-radius: 50%;
				vertical-align: middle;
			}
			.lv{
				width: 80rpx;
				height: 40rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				opacity: 1;
				border: 2rpx solid #FF9101;
				position: absolute;
				text-align: center;
				bottom: 16rpx;
				left: 20rpx;
				color: #FF9101;
				line-height: 40rpx;
				// padding: 0 20rpx;
			}
			.lvs{
				width:130rpx;
				height: 40rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				opacity: 1;
				border: 2rpx solid #FF9101;
				position: absolute;
				text-align: center;
				bottom: 16rpx;
				
				color: #FF9101;
				line-height: 40rpx;
			}
		}
		.topRight{
			width: 55%;
			margin: 52rpx 0 0 32rpx;
			font-size: 18px;
			color: #333333;
			.topName{
				font-size: 12px;
				line-height: 40rpx;
			}
		}
		.topRights{
			margin-top: 37px;
			width: 65px;
			height: 26px;
			border: 1px solid #FFFFFF;
			opacity: 1;
			border-radius: 14px;
			font-size: 12px;
			font-family: PingFang SC;
			font-weight: 500;
			line-height: 26px;
			color: #999999;
			text-align: center;
		}
	}
	.myBuy{
		height: 121px;
		background: #FFFFFF;
		border-radius: 16rpx;
		.buyTop{
			width: 90%;
			margin: auto;
			display: flex;
			justify-content: space-between;
			font-size: 14px;
			height: 120rpx;
			line-height: 120rpx;
			color: #000000;
			.allList{
				font-size: 12px;
				color: #999999;
			}
		}
		.buList{
			width:80%;
			margin: auto;
			display: flex;
			justify-content: space-between;
			text-align: center;
			font-size: 12px;
			color: #666666;
			image{
				width: 40rpx;
				height: 40rpx;
				margin-bottom: 16rpx;
			}
		}
	}
	.myMoney{
		width: 100%;
		background-color: #fff;
		border-radius: 16rpx;
		height: 176rpx;
		text-align: center;
		justify-content: space-between;
		margin-top: 20rpx;
		.moneyList{
			width: 40%;
			text-align: center;
			font-size: 12px;
			font-weight: 500;
			color: #666666;
			.top{
				font-size: 20px;
				font-family: Arial-Bold, Arial;
				font-weight: bold;
				color: #333333;
			}
		}
	}
	.myBtm{
		margin-top: 22rpx;
		// height: 311px;
		background: #FFFFFF;
		border-radius: 16rpx;
	}
	.myList{
		width: 90%;
		margin: auto;
		display: flex;
		/*height: 100rpx;*/
		line-height: 100rpx;
		justify-content: space-between;
		border-bottom: 1px solid #F2F2F2;
		.img{
			width: 10%;
			image{
				width: 40rpx;
				height: 40rpx;
				vertical-align: middle;
			}
		}
		.listName{
			width: 90%;
			font-size: 14px;
			color: #666666;
		}
		.right{
			image{
				width: 12rpx;
				height: 22rpx;
			}
		}
	}
}
.showBox{
	width: 600rpx;
	height: 636rpx;
	border-radius: 16rpx;
	.showName{
		image{width: 40rpx;height: 40rpx;vertical-align: middle;margin-right: 10rpx;}
		text-align: center;
		padding-top: 40rpx;
		margin-bottom: 40rpx;
	}
	.showBoxs{
		width: 85%;
		margin: auto;
		font-size: 12px;
		color: #fff;
		flex-direction: row;
		flex-wrap: wrap;
		.showOne,.showTwo,.showFour,.showFive{
			width: 120rpx;
			height: 120rpx;
			background: #E6E6E6;
			text-align: center;
			margin-bottom: 20rpx;
			.name{
				margin-top:24rpx;
			}
		}
		.showOne{
			border-radius: 8px 0px 0px 0px;
		}
		.showFour{
			border-radius: 0px 8px 0px 0px;
		}
		.showFive{
			border-radius: 0px 0px 0px 8px;
		}
		.showSeven{
			width: 250rpx;
			height: 120rpx;
			background: #E6E6E6;
			border-radius: 0px 0px 8px 0px;
			text-align: center;
			margin-top: -16rpx;
			.name{
				margin-top:24rpx;
			}
		}
	}
	.showBtn{
		width: 320rpx;
		height: 100rpx;
		line-height: 100rpx;
		margin: 40rpx auto 20rpx auto;
		color: #fff;
		background: #FF9101;
		border-radius: 50rpx;
		text-align: center;
	}
	.showText{
		text-align: center;
		color: #999999;
		font-size: 14px;
		text{
			color: #FF9101;
		}
	}
}
.bg{
	background-color: #FF9101!important;
}
</style>
